<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>naonao主页(测试页面)</title>
</head>
<body>
  <h1>NaoNao数据测试页面</h1>
  <button type="button" id="getData" onclick="getDataFunc()">获取数据</button>
  <p id="data">{{ data }}</p>
</body>
<script src="/static/rest_framework/js/jquery-1.12.4.min.js" type="text/javascript"></script>
<script type="text/javascript">
function getDataFunc(){
  // 暴露的是nginx的接口
  var url = "http://127.0.0.1:8088/students/"
    $.ajax({
        url: url,
        type: 'GET',
        contentType: "application/json; charset=utf-8",
        dataType: 'text',
        cache: false,
        success: replaceData,
        error: errorMessage,
    });
}


function replaceData(data){
  $("#data").html(data);
  console.log(data);
}
function errorMessage(mes){
  alert(mes);
}
</script>
</html>
